package com.edu.controller;

import com.edu.entity.Process;
import com.edu.service.impl.ProcessServiceImpl;
import com.edu.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: graduate
 * @description: 流程管理
 * @author: 管浩杰
 * @create: 2021-05-27 22:00
 **/
@RestController
@RequestMapping("process")
public class ProcessController {

    @Autowired
    private ProcessServiceImpl processService;

    /**
     * 查询所有的process
     * */
    @GetMapping("queryAllProcess")
    public Result queryAllProcess(){
        List<Process> list = processService.list(null);
        if(CollectionUtils.isEmpty(list)){
            return Result.failure("555", "查询错误");
        }
        return Result.success(list);
    }


    /**
     * 修改
     * id 必须传
     * */

    @PutMapping("updateProcess")
    public Result updateProcess(@RequestBody Process process){
        if(null == process.getId()){
            return Result.failure();
        }
        processService.saveOrUpdate(process);
        return Result.success();
    }





}
